LocalActivity = LocalServerBaseHandler.New()

local t = LocalActivity
function t:Register()
    self:RegisterReq(193101) --请求转盘活动信息
    self:RegisterReq(193102) --请求转盘排行榜信息
    self:RegisterReq(193103) --请求转盘任务列表信息
    self:RegisterReq(193105)--请求领取转盘任务奖励
    self:RegisterReq(193106)--请求领取转盘充值奖励

end
function t:Receive(msg)
    if msg.msgId == 193101 then--请求转盘活动信息
        local m = ResTurntableActivityInfoMessage.New()
        m.activityId = msg.activityId
        m.activityInfo = TurntableActivityInfo.New()
        m.activityInfo.activityId = msg.activityId
        m.activityInfo.todayTurnCount = 0
        m.activityInfo.insureCount = 1
        m.activityInfo.totalPay = 99
        m.activityInfo.recvCount = 1
        LocalServer.Send(m)
    elseif msg.msgId == 193102 then --请求转盘排行榜信息
        local m = ResTurntableRankListInfoMessage.New()
        m.activityId = msg.activityId
        m.rankType = msg.rankType
        m.rankList = {}
        for i = 0,10 do
            local info = TurntableRankInfo.New()
            info.playerId = i
            info.name = "test"..i
            info.pic = logicMgr.HeroManager.GetRoleHeadID()
            info.picFrame = logicMgr.HeroManager.GetRoleHeadFrame()
            info.lv = i
            info.orderVal = 10000*i
            table.insert(m.rankList,info)
        end
        m.selfRank = 3
        m.selfOrderVal = 14000
        m.rankVersion = msg.rankVersion + 1
        LocalServer.Send(m)
    elseif msg.msgId == 193103 then--请求转盘任务列表信息
        local m = ResTurntableTaskListInfoMessage.New()
        m.activityId = msg.activityId
        m.taskList = {}
        local info = TurntableTaskInfo.New()
        info.taskId = 1900101
        info.process = 12
        info.recvStatus = 0
        table.insert(m.taskList,info)
        info = TurntableTaskInfo.New()
        info.taskId = 1900141
        info.process = 12
        info.recvStatus = 0
        table.insert(m.taskList,info)
        info = TurntableTaskInfo.New()
        info.taskId = 1900142
        info.process = 68
        info.recvStatus = 0
        table.insert(m.taskList,info)
        LocalServer.Send(m)
    elseif msg.msgId == 193105 then--请求领取转盘任务奖励
        local cfg = dataTable.getDataTableByStringId("t_periodtask",msg.taskId)
        local m = ResRecvTurntableTaskAwardMessage.New()
        m.activityId = msg.activityId
        m.taskId = msg.taskId
        m.items = self:ParseItemInfoList(cfg.f_Award)
        LocalServer.Send(m)
    elseif msg.msgId == 193106 then--请求领取转盘充值奖励
        local cfg = dataTable.getDataTableByStringId("t_periodtask",msg.taskId)
        local m = ResRecvTurntableTaskAwardMessage.New()
        m.activityId = msg.activityId
        m.taskId = msg.taskId
        m.items = self:ParseItemInfoList(cfg.f_Award)
        LocalServer.Send(m)
    end
end
function t:ParseItemInfoList(json)
    local tb = decodeJsonStrToTabel(json)
    local rewards = {}
    for k, v in pairs(tb) do
        local data = {};
        data["itemModelId"] = v[1]
        data["num"] = v[2]
        table.insert(rewards, data)
    end
    return rewards
end
